Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: define wrappers around package that point to internals #1573

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

ss2165
Copy link
Member

@ss2165 ss2165 commented Oct 11, 2024

Closes #1561

So far just top level things, can add inner ones (cfg, blocks, etc.) later.

BREAKING CHANGE: Package moved to new hugr.package module

Closes #1561

So far just top level things, can add inner ones (cfg, blocks, etc.) later.

BREAKING CHANGE: `Package` moved to new `hugr.package` module
@ss2165 ss2165 requested a review from a team as a code owner October 11, 2024 13:28
@ss2165 ss2165 requested a review from aborgna-q October 11, 2024 13:28
@aborgna-q aborgna-q linked an issue Oct 11, 2024 that may be closed by this pull request
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 93.22034% with 4 lines in your changes missing coverage. Please review.

Project coverage is 85.69%. Comparing base (d03b91e) to head (477a365).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
hugr-py/src/hugr/package.py 93.22% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1573      +/-   ##
==========================================
+ Coverage   85.68%   85.69%   +0.01%     
==========================================
  Files         134      135       +1     
  Lines       24512    24563      +51     
  Branches    21512    21512              
==========================================
+ Hits        21003    21050      +47     
- Misses       2411     2415       +4     
  Partials     1098     1098              
Flag Coverage Δ
python 92.46% <93.22%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 52 to 54
def get_package(self) -> Package:
"""Get the package pointed to."""
return self.package
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(vestigial from original issue which proposed protocols)

Comment on lines +63 to +65
def module(self) -> Hugr:
"""Hugr definition of the module."""
return self.package.modules[self.module_index]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a property (same for all other methods in this PR)

Copy link
Collaborator

@aborgna-q aborgna-q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

The followup question will now be how do we serialize these :)

"""Create an executable package from a module containing a main function.

Raises:
StopIteration: If the module does not contain a main function.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rethrow a more appropriate exception, with a custom message.
Either a custom one, or ValueError

"""Hugr definition of the module."""
return self.package.modules[self.module_index]

def to_executable_package(self) -> "ExecutablePackage":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from __future__ import annotations

and remove the quotes

hugr-py/src/hugr/package.py Show resolved Hide resolved
hugr-py/src/hugr/package.py Show resolved Hide resolved
hugr-py/src/hugr/package.py Show resolved Hide resolved
@ss2165 ss2165 enabled auto-merge October 11, 2024 14:26
@ss2165 ss2165 added this pull request to the merge queue Oct 11, 2024
Merged via the queue into main with commit f74dbf3 Oct 11, 2024
20 checks passed
@ss2165 ss2165 deleted the ss/point-package branch October 11, 2024 14:31
github-merge-queue bot pushed a commit that referenced this pull request Oct 14, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.9.0](hugr-py-v0.8.1...hugr-py-v0.9.0)
(2024-10-14)


### ⚠ BREAKING CHANGES

* `Package` moved to new `hugr.package` module
* The `length` op in the std `collections` extensions now also returns
the list.

### Features

* `instantiate` method for `OpDef`
([#1576](#1576))
([36548ab](36548ab)),
closes [#1512](#1512)
* define wrappers around package that point to internals
([#1573](#1573))
([f74dbf3](f74dbf3))
* to/from json for extension/package
([#1575](#1575))
([f8bf61a](f8bf61a)),
closes [#1523](#1523)


### Bug Fixes

* Make list length op give back the list
([#1547](#1547))
([cf31698](cf31698))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Agustín Borgna <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

py: Add a "Pointed package" protocol
3 participants